package object2;

import java.lang.Override;

/**
 * 面向对象编程（中级部分）练习
 */
public class Object2Exercise03 {

    public static void main(String[] args) {

        /*
            通过继承实现员工工资核算打印功能
            父类：员工类(Employee)
            子类：部门经理类(Manager)、普通员工(Worker)
            1)部门经理工资=1000 + 单日工资 * 天数 * 等级(1.2) => 奖金 + 基本工资
            2)普通员工工资=单日工资 * 天数* 等级(1.0) =>基本工资
            3)员工属性：姓名、单日工资、工作天数
            4)员工方法(打印工资)
            5)普遍员工及部门经理都是员工子类，需要重写打印工资的方法
            6)定义并初始化普通员工对象，调用打印工资方法输出工资，定义并初始化部门经理对象，调用打印工资的方法输出工资
         */
        Workers workers = new Workers("张三", 300.0, 25);
        workers.printInfo();

        Managers managers = new Managers("李四", 400.0, 30);
        managers.printInfo();
    }
}

class Employees {

    public String name;

    public double daySalary;

    public int workDay;

    public Employees(String name, double daySalary, int workDay) {
        this.name = name;
        this.daySalary = daySalary;
        this.workDay = workDay;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getDaySalary() {
        return daySalary;
    }

    public void setDaySalary(double daySalary) {
        this.daySalary = daySalary;
    }

    public int getWorkDay() {
        return workDay;
    }

    public void setWorkDay(int workDay) {
        this.workDay = workDay;
    }

    public void printInfo() {
        System.out.println("姓名：" + name + ",工资=" + daySalary * workDay);
    }
}

class Managers extends Employees {

    public Managers(String name, double daySalary, int workDay) {
        super(name, daySalary, workDay);
    }

    @Override
    public void printInfo() {
        double salary = 1000 + this.daySalary * workDay * 1.2;
        System.out.println("姓名：" + name + ",工资=" + salary);
    }
}

class Workers extends Employees {

    public Workers(String name, double daySalary, int workDay) {
        super(name, daySalary, workDay);
    }

    @Override
    public void printInfo() {
        super.printInfo();
    }

}